package com.micosco.taskremind.data;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.TypeConverters;

@Database(entities = {Task.class}, version = 1, exportSchema = false)//数据库版本号：1
@TypeConverters({LocalDateConverter.class, LocalDateTimeConverter.class, RemindType.class})
public abstract class TaskDatabase extends RoomDatabase {
    private static TaskDatabase instance;

    public static void createInstance(Context context) {
        synchronized (TaskDatabase.class) {
            if (context != null) {
                instance = Room.databaseBuilder(context.getApplicationContext(),
                        TaskDatabase.class, "tasks").build();
            }
        }
    }

    public static TaskDatabase getInstance() {
        return instance;
    }

    public abstract TaskDAO taskDAO();
}
